#!/bin/bash
########################################################################
#    (C)2010 Jimmy M. Coleman (aka hyperclock)
#	 website:  www.cybernux.org
#	 email:    hyperclock(at)cybernux(dot)org
#	 code:	   http://code.google.com/p/dforker/
########################################################################
########################################################################
#    This file is part of DForker.
#
#    DForker is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    DForker is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with DForker.  If not, see <http://www.gnu.org/licenses/>.
#
########################################################################

# -----------------------
# Define Colors for MSGs
# -----------------------
# Reset
Color_Off='\e[0m'       # Text Reset

# Regular Colors
Black='\e[0;30m'        # Black
Red='\e[0;31m'          # Red
Green='\e[0;32m'        # Green
Yellow='\e[0;33m'       # Yellow
Blue='\e[0;34m'         # Blue
Purple='\e[0;35m'       # Purple
Cyan='\e[0;36m'         # Cyan
White='\e[0;37m'        # White

# Bold
BBlack='\e[1;30m'       # Black
BRed='\e[1;31m'         # Red
BGreen='\e[1;32m'       # Green
BYellow='\e[1;33m'      # Yellow
BBlue='\e[1;34m'        # Blue
BPurple='\e[1;35m'      # Purple
BCyan='\e[1;36m'        # Cyan
BWhite='\e[1;37m'       # White

# Underline
UBlack='\e[4;30m'       # Black
URed='\e[4;31m'         # Red
UGreen='\e[4;32m'       # Green
UYellow='\e[4;33m'      # Yellow
UBlue='\e[4;34m'        # Blue
UPurple='\e[4;35m'      # Purple
UCyan='\e[4;36m'        # Cyan
UWhite='\e[4;37m'       # White

# Background
On_Black='\e[40m'       # Black
On_Red='\e[41m'         # Red
On_Green='\e[42m'       # Green
On_Yellow='\e[43m'      # Yellow
On_Blue='\e[44m'        # Blue
On_Purple='\e[45m'      # Purple
On_Cyan='\e[46m'        # Cyan
On_White='\e[47m'       # White

# High Intensty
IBlack='\e[0;90m'       # Black
IRed='\e[0;91m'         # Red
IGreen='\e[0;92m'       # Green
IYellow='\e[0;93m'      # Yellow
IBlue='\e[0;94m'        # Blue
IPurple='\e[0;95m'      # Purple
ICyan='\e[0;96m'        # Cyan
IWhite='\e[0;97m'       # White

# Bold High Intensty
BIBlack='\e[1;90m'      # Black
BIRed='\e[1;91m'        # Red
BIGreen='\e[1;92m'      # Green
BIYellow='\e[1;93m'     # Yellow
BIBlue='\e[1;94m'       # Blue
BIPurple='\e[1;95m'     # Purple
BICyan='\e[1;96m'       # Cyan
BIWhite='\e[1;97m'      # White

# High Intensty backgrounds
On_IBlack='\e[0;100m'   # Black
On_IRed='\e[0;101m'     # Red
On_IGreen='\e[0;102m'   # Green
On_IYellow='\e[0;103m'  # Yellow
On_IBlue='\e[0;104m'    # Blue
On_IPurple='\e[10;95m'  # Purple
On_ICyan='\e[0;106m'    # Cyan
On_IWhite='\e[0;107m'   # White

# ----------------------
# Make sure you're root
# ----------------------
if [ $UID != 0 ]; then
	echo -e "\e[0;31mThis script must be run as root\e[m"
	exit 1
fi

# --------------------------
# Get some debugging output
# If you want less change 
# the "-" to "+"
# --------------------------
set -ex

# ---------------------
# Distro related stuff
# ---------------------
DIST_NAME="Cybernux"
DIST_NAME_S="echo $DIST_NAME | tr 'A-Z' 'a-z'"
DIST_NAME_L="Cybernux Linux"
DIST_VERS="0.1"
REPO_KEY="310D7D6D"
CODE_NAME="othala"
[ -z $RELEASE ] && RELEASE=$CODE_NAME

export MAINT_INFO='$DIST_NAME_L DevTeam <devteam@cybernux.org>'
UPDATES=1
BACKPORTS=0
REPO_ARCHES="i386 amd64"
BASE_DIR=/opt/$DIST_NAME_S
BLD_REPO=http://127.0.0.1/$DIST_NAME_S
DOMAIN=$DIST_NAME_S.org
RSYNC_DEST=sandbox@archive.$DOMAIN:/opt/$DIST_NAME_S-$CODE_NAME/
RSYNC_OPTIONS="--partial"

# ------------------------
# REPOS USED FOR BUILDING
# ------------------------

# MAIN REPO
LOCAL_MIRROR=/debian-mirror/debian/
MIRROR=http://127.0.0.1/debian-mirror/debian/
MIRROR_DIST=squeeze

# UPDATES REPO - reviously known as 'volatile'
UPD_LOCAL_MIRROR=/debian-mirror/debian-updates/
UPD_MIRROR=http://127.0.0.1/debian-mirror/debian-updates/
UPD_MIRROR_DIST=squeeze-updates

# SECURITY REPO
SEC_LOCAL_MIRROR=/debian-mirror/debian-security/
SEC_MIRROR=http://127.0.0.1/debian-mirror/debian-security/
SEC_MIRROR_DIST=squeeze/updates

# -------------------------------------------------
# Version numbers appended to newly developed .deb
# -------------------------------------------------
APT_VERSION=1
BASE_FILES_VERSION=1
META_VERSION=1
KMETA_VERSION=1
GNOME_DESKTOP_VERSION=1
GNOME_PANEL_VERSION=1

# ------
# PATHS
# ------
WORK_ENV=$BASE_DIR/tmp
LIVE_CD_DIR=$BASE_DIR/livecd
REPO_DEST=$BASE_DIR/$DIST_NAME_S

# -------------------------
# DON'T CHANGE OR REMOVE
# THESE ARE IMPORTANT
# FOR PROPER USE
# ------------------------

if [ 1 == $UPDATES ]; then EXTRAS="-updates"; fi
if [ 1 == $BACKPORTS ]; then EXTRAS="$EXTRAS -backports"; fi

# -------------------------------------
# Use "amd64" or "i386" below
# depending on your build architecture
# -------------------------------------
if [ -z $BUILD_ARCH ]; then
	BUILD_ARCH="amd64"
fi

# -------------------------
# DON'T CHANGE OR REMOVE
# THESE ARE IMPORTANT
# FOR PROPER USE
# ------------------------

case $BUILDARCH in
	386 | i386 | I386 | ia32 | IA32)
		export HOST_ARCH="i386";
		export KERNEL_ARCH="386";
		export DPKG_OPTS='-rfakeroot -e"$MAINT_INFO" -m"$MAINT_INFO" -us -uc -ai386';
	;;
	amd64 | AMD64)
		export HOST_ARCH="amd64";
		export KERNEL_ARCH="amd64";
		export DPKG_OPTS='-rfakeroot -e"$MAINT_INFO" -m"$MAINT_INFO" -us -uc -B -aamd64';
	;;
	*)
	echo -e "\n\nERROR\! invalid arch\!\n\n"
	exit 1
	;;
esac

case $(tr A-Z a-z <<<$MIRROR_DIST) in
	"squeeze")
		export KERNEL_RELEASE="2.6.32"
		;;
	*)
		exit 1
		;;
esac

# -------------------
# DO NOT REMOVE
# OR PLACE ELSEWHERE
# WILL CAUSE PROBS
# ------------------
LANG=C
